package com.wqtz.chechai.view.activities;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.wqtz.chechai.R;
import com.wqtz.chechai.base.BaseActivity;
import com.wqtz.chechai.presenter.BasePresent;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 项目名称： CheChai
 * 创建人 : Liberation
 * 创建时间: 2017/2/23 11:53
 */

public class AdvanceSearchActivity extends BaseActivity {
	@BindView(R.id.iv_back)
	ImageView mIvBack;
	@BindView(R.id.tv_title)
	TextView mTvTitle;
	@BindView(R.id.tv_status)
	TextView mTvStatus;
	@BindView(R.id.ll_status)
	LinearLayout mLlStatus;
	@BindView(R.id.tv_time)
	TextView mTvTime;
	@BindView(R.id.ll_time)
	LinearLayout mLlTime;
	final int REQUEST_STATUS = 10020;
	final int REQUEST_TIME = 10021;
	@BindView(R.id.btn_confirm)
	Button mBtnConfirm;
	private String status = "";
	private String time = "";
	private int statusPos; //status的位置
	private int timePos; //time的位置
	private int statusType;//状态类型
	private int timeType;//时间类型

	@Override
	public void init() {
		ButterKnife.bind(this);
	}

	@Override
	public void loadData() {

	}

	@Override
	public int setContentViews() {
		return R.layout.activity_adsearch;
	}

	@Override
	public BasePresent createPresenter() {
		return null;
	}


	@OnClick({R.id.iv_back, R.id.ll_status, R.id.ll_time,R.id.btn_confirm})
	public void onClick(View view) {
		switch (view.getId()) {
			case R.id.iv_back:
				finish();
				break;
			case R.id.ll_status:
				Intent intent = new Intent(this, SearchByStatusActivity.class);
				intent.putExtra("position", statusPos);
				startActivityForResult(intent, REQUEST_STATUS);
				break;
			case R.id.ll_time:
				Intent intent2 = new Intent(this, SearchByTimeActivity.class);
				intent2.putExtra("time", status);
				startActivityForResult(intent2, REQUEST_TIME);
				break;
			case R.id.btn_confirm:{
				Intent intent3 = new Intent(this,SearchResultActivity.class);
				intent3.putExtra("statusType",statusType);
				intent3.putExtra("timeType",timeType);
				startActivity(intent3);
			}break;
		}
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if (RESULT_OK == resultCode) {
			switch (requestCode) {
				case REQUEST_STATUS: {
					statusPos = data.getIntExtra("position", 0);
					mTvStatus.setText(status = data.getStringExtra("status"));
					statusType = data.getIntExtra("type", 0);
				}
				break;
				case REQUEST_TIME: {
					timePos = data.getIntExtra("time", 0);
					mTvTime.setText(time = data.getStringExtra("time"));
				}
				break;
			}
		}

	}

}
